<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
				xmlns:f="http://java.sun.com/jsf/core"
			    xmlns:h="http://java.sun.com/jsf/html" 
			    xmlns:ui="http://java.sun.com/jsf/facelets">
        
    <script type="text/javascript">
  	//<![CDATA[
  	
  		function controlError(data) {																
			//Gestion de Error			
			if (data.status == "success"){
				var bError = false;				
				$("#form2 span").each(function() {				
					if($(this) != null && $(this).text().length > 3){
						bError = true;
					}								
				});
				if(bError){
					$("#contrasenaDialog").parent().effect("shake", "slow");
				}else{
					$('#contrasenaDialog').dialog('close');
				}
			}
			
			bError = false;
  		}
  	       
  		function cerrarDialog(){
  			$("#form2 span").each(function() {				
				if($(this) != null && $(this).text().length > 3){
					$(this).hide();
				}								
			});
  			$('#contrasenaDialog').dialog('close');
  		}
  	           
  	//]]>
    </script>    
	 <h:form id="form2">					   				   
	   	<p>                		
	   		<h:outputLabel value="Contraseña Antigua " for="contrasenaOld" /><br/>                		
	   		<h:inputSecret id="contrasenaOld" required="true" value="#{clienteBean.contrasena}" validator="passwordValidatorDatosPersonales" />
	   		<h:message for="contrasenaOld" errorClass="error" />
	   	</p>																
		<p>
			<h:outputLabel value="Nueva Contraseña" for="contrasenaNew1" /><br/>
			<h:inputSecret id="contrasenaNew1" required="true" value="#{datosPersonalesBean.contrasenaNew1}" validator="passwordValidator" />						
			<h:message for="contrasenaNew1" errorClass="error" /><br/>
		
			<h:outputLabel value="Confirma la contraseña" for="contrasenaNew2" /><br/>
			<h:inputSecret id="contrasenaNew2" required="true" value="#{datosPersonalesBean.contrasenaNew2}" validator="passwordConfirmacionValidator" />
			<h:message for="contrasenaNew2" errorClass="error" />											
		</p>					
		<div class="footer">
			<div class="line-separator" style="margin-bottom: 6px;" />						
			<h:panelGroup style="float: right;">						
				<h:commandButton styleClass="g-button g-button-submit" value="Guardar" action="#{contrasenaController.cambiarContrasena()}">														
					<f:ajax execute="form2" render="form2" onevent="controlError" />
				</h:commandButton>
				<h:commandButton styleClass="g-button g-button-submit" onclick="cerrarDialog()" value="Cancelar">							
					<f:ajax execute="@this" />
				</h:commandButton>			
			</h:panelGroup>
		</div>
	</h:form>	
</ui:composition>	